<template>
	<view>
		<TopNav title="押金记录"></TopNav>
		<view class="padding-tb-xs" v-if="total !== 0">
			<u-loadmore :status="loadmoreStatus" line @loadmore="handleScrollBottom" />
		</view>
		<Empty :show="total === 0"></Empty>
	</view>
</template>

<script>
	import Empty from "@/components/empty/index.vue"
	import mixins from "@/mixins/index.js"
	import {cashPledgeList} from "@/api/mine"
	export default {
		components:{Empty},
		mixins: [mixins],
		data() {
			return {
				list: [],
				queryParams: {
					page: 1,
					limit: 10
				},
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList() {
				cashPledgeList(this.queryParams).then(res => {
					let {
						data: {
							list,
							count,
							total
						}
					} = res
					this.total = count || 0
					this.pageTotal = total || 0
					if (this.queryParams.page === this.pageTotal) this.loadmoreStatus = 'nomore'
					if (this.queryParams.page === 1) {
						this.list = list
					} else if (this.queryParams.page < this.pageTotal) {
						this.list = this.list.concat(list)
					}
				})
			},
		}
	}
</script>

<style>

</style>
